package com.iwuke.dance.http_request;

import java.io.IOException;

import okhttp3.Interceptor;
import okhttp3.Request;
import okhttp3.Response;

public  class LoggingInterceptor2 implements Interceptor {

    @Override public Response intercept(Chain chain) throws IOException {
//        Request request = chain.request();
//
//        long t1 = System.nanoTime();
//        Logger.i(String.format("Sending request %s on %s%n%s", request.url(), chain.connection(), request.headers()));
//
//        Response response = chain.proceed(request);
//
//        long t2 = System.nanoTime();
//        Logger.i(String.format("Received response for %s in %.1fms%n%s",
//                response.request().url(), (t2 - t1) / 1e6d, response.headers()));


        // get token
        //String token = AppService.getToken();
        Request originalRequest = chain.request();
        // get new request, add request header  请求头
        //FileLog.getInstance().saveLog2("----------", "\n"+ Util.getToken());
        Request updateRequest = originalRequest.newBuilder()
                //.header("token", Util.getToken())
                //.header("token", "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE2NDQ4OTc4MzIsInVzZXJuYW1lIjoiYWRtaW4iLCJpZCI6MX0.-JBQJMG7ism8YVLckgkcBqhB4Oi0lSHQcTFzv5Fe6Zw")
                .build();
        Response response = chain.proceed(updateRequest);
        return response;
    }
}



